/*
 * The MIT License
 *
 * Copyright (c) 2010, Bharathwaaj Srinivasan, bluegenetic@gmail.com, bharathwaaj.s@gmail.com
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

#ifndef PRIVATE_H
#define PRIVATE_H

#ifdef __cplusplus
extern "C" {
#endif

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include "curltweet_api.h"

typedef enum ctParseTag
{
    PARSE_STATUS,
    PARSE_STATUSES,
    PARSE_USERS,
    PARSE_DIRECT_MESSAGES,
    PARSE_RELATIONSHIP,
    PARSE_ID_LIST,
    PARSE_SAVED_SEARCH,
    PARSE_LOCATIONS,
} ParseTag;

struct CurlTweetTag
{
    CURL *p_s_curlHandle;
    ezxml_t p_s_xml;
    uint8_t a_u8_username[CURLTWEET_MAX_USERNAME_SIZE];
    uint8_t  a_u8_passwd[CURLTWEET_MAX_PASSWORD_SIZE];
    uint8_t *p_u8_payload;
    uint32_t u32_dataReceived;
    uint32_t u32_contentLength;
    int32_t s32_dataFullyReceived;
    bool_t eb_loggedIn;
};

size_t ct_header_callback( void *p_v_data, size_t size, size_t nmemb, void *p_v_userdata);
size_t ct_message_callback( void *p_v_data, size_t size, size_t nmemb, void *p_v_userdata);
CtError ct_prepare_nw(CurlTweet p_s_ctHandle, uint8_t *p_u8_url, uint8_t *p_u8_postData);
CtError ct_parse_xml(CurlTweet p_s_ctHandle, void *p_v_output, ParseTag e_parse);
CtError ct_parse_statuses(ezxml_t p_s_xml, StatusRoot *p_s_statuses);
CtError ct_parse_status(ezxml_t p_s_statusToken, Status *p_s_status, uint32_t s32_index);
CtError ct_parse_userInfo(ezxml_t p_s_statusToken, UserInfo *p_s_userInfo);
CtError ct_fetch_and_parse (CurlTweet p_s_ctHandle, void *p_v_output,
                                                       ParseTag e_parse, uint8_t *p_u8_url);

#ifdef __cplusplus
}
#endif

#endif /* PRIVATE_H ENDS HERE */
